package spring.demo.ioc.test;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import spring.demo.ioc.domain.Account;
import spring.demo.ioc.persistence.AccountDao;
import spring.demo.ioc.persistence.AccountDaoImpl;
import spring.demo.ioc.service.AccountService;

public class Demo {
//    @Test
    public static void test()
    {
//        AccountDao accountDao = new AccountDaoImpl();
        //使用spring的IoC获取对象
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); // 获取一个上下文，初始化spring的环境
//        Account account = (Account) context.getBean("account");
//        System.out.println(account.getUsername() + " " + account.getPassword() + " " + account.getAge());
        AccountService accountService = (AccountService) context.getBean("accountService");
        accountService.login();
////        AccountDao accountDao = (AccountDao) context.getBean("accountDao");
////
////
////        accountDao.insert();
////        accountDao.delete();
////        accountDao.find();
////        accountDao.update();

    }

    public static void main(String[] args) {
        test();
    }

}
